<template>
  <div>
    <eagle-list
      showTab
      :tabData="tabData"
      @initActive="_initActive"
      @bindData="bindData"
      allowSearch
      :placeholder="placeholder1"
      ref="eaglelist"
    >
      <div v-if="this.active === 0">
        <div v-if="GuidelineEntrustedRegList!=null">
          <eagle-cell
            v-for="(item, index) in GuidelineEntrustedRegList"
            :key="index"
            style="margin-top: 10px"
            class="card"
          >
            <div>
              <div @click="goDetail(item)">
                <eagle-row>
                  <eagle-col>
                    <b style="font-size: 13px">{{ item.HandBookName }}</b>
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="12">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_equ_property.png"
                      alt=""
                    />版本：{{ item.VersionNo }}
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />实施日期：{{ item.EditDate }}
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />最近修改人：{{ item.EditChnName }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />最近修改时间：{{ item.EditDate }}
                  </eagle-col>
                </eagle-row>
              </div>
            </div>
          </eagle-cell>
        </div>
        <div v-if="RegulationOperationList!=null">
          <eagle-cell
            style="margin-top: 10px"
            class="card"
            v-for="(item, index) in RegulationOperationList"
            :key="index"
          >
            <div>
              <div @click="goDetail(item)">
                <eagle-row>
                  <eagle-col>
                    <b style="font-size: 13px">{{ item.OperateRuleName }}</b>
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="12">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_equ_property.png"
                      alt=""
                    />版本：{{ item.VersionNo }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />实施日期：{{ item.EditDate | formatDateTime }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="20">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_group.png"
                      alt=""
                    />适用岗位：{{ item.ApplyOrgAndPostName }}
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />最近修改人：{{ item.EditChnName }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />最近修改时间：{{ item.EditDate }}
                  </eagle-col>
                </eagle-row>
              </div>
            </div>
          </eagle-cell>
        </div>
      </div>
      <div v-if="this.active === 1">
        <div v-if="GuidelineEntrustedRegList!=null">
          <eagle-cell
            style="margin-top: 10px"
            class="card"
            v-for="(item, index) in GuidelineEntrustedRegList2"
            :key="index"
          >
            <div>
              <div @click="goDetail(item)">
                <eagle-row>
                  <eagle-col>
                    <b style="font-size: 13px">{{ item.HandBookName }}</b>
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="20">
                    <img
                      src="@/assets/Images/AppIcon/icon_equ_property.png"
                      alt=""
                      class="icon"
                    />版本：{{ item.VersionNo }}
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                      class="icon"
                    />最近修改人：{{ item.EditChnName }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />最近修改时间：{{ item.EditDate }}
                  </eagle-col>
                </eagle-row>
              </div>
            </div>
          </eagle-cell>
        </div>
        <div v-if="RegulationOperationList2!=null">
          <eagle-cell
            style="margin-top: 10px"
            class="card"
            v-for="(item, index) in RegulationOperationList2"
            :key="index"
          >
            <div>
              <div @click="goDetail(item)">
                <eagle-row>
                  <eagle-col>
                    <b style="font-size: 13px">{{ item.OperateRuleName }}</b>
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="20">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_equ_property.png"
                      alt=""
                    />版本：{{ item.VersionNo }}
                  </eagle-col>

                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="20">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_group.png"
                      alt=""
                    />适用岗位：{{ item.ApplyOrgAndPostName }}
                  </eagle-col>
                </eagle-row>
                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_user.png"
                      alt=""
                    />最近修改人：{{ item.EditChnName }}
                  </eagle-col>
                </eagle-row>

                <eagle-row
                  gutter="20"
                  class="dep_sort"
                >
                  <eagle-col span="24">
                    <img
                      class="icon"
                      src="@/assets/Images/AppIcon/icon_list_date.png"
                      alt=""
                    />最近修改时间：{{ item.EditDate }}
                  </eagle-col>
                </eagle-row>
              </div>
            </div>
          </eagle-cell>
        </div>
      </div>
    </eagle-list>
  </div>
</template>
<script>
import store from "@/store/index";
export default {
  data() {
    return {
      title1: this.$route.query.title1,
      title2: this.$route.query.title2,
      titleCode: this.$route.query.titleCode,
      GuidelineEntrustedRegList: [],
      GuidelineEntrustedRegList2: [],
      RegulationOperationList: [],
      RegulationOperationList2: [],
      active: 0,
      tabData: [],
      placeholder1: "",
    };
  },
  created() {
    let title;
    if (this.$route.query.titleCode == "RegulationManual") {
      this.placeholder1 = "请输入手册名称,最近修改人搜索";
      this.tabData.push(
        {
          title: this.title1,
          url: "/GuidelineHandBook/GetPageData",
          isPage: true,
          params: {
            dataType: "Publish",
          },
        },
        {
          title: this.title2,
          url: "/GuidelineHandBook/GetPageData",
          isPage: true,
          params: {
            dataType: "Consultation",
          },
        }
      );
    } else if (this.$route.query.titleCode == "RegulationOperation") {
      this.placeholder1 = "请输入操作规程名称,适用岗位,最近修改人搜索";
      this.tabData.push(
        {
          title: this.title1,
          url: "/GuidelineOperateRule/GetPageData",
          isPage: true,
          params: {
            dataType: "Publish",
          },
        },
        {
          title: this.title2,
          url: "/GuidelineOperateRule/GetPageData",
          isPage: true,
          params: {
            dataType: "Consultation",
          },
        }
      );
    }
  },
  methods: {
    _initActive(active) {
      this.active = active;
    },
    bindData(data) {
      let title;
      let originType = this.$route.query.titleCode;
      if (originType == "RegulationManual") {
        if (this.active === 0) {
          this.GuidelineEntrustedRegList = data;
        } else if (this.active === 1) {
          this.GuidelineEntrustedRegList2 = data;
        }
        title = "管理手册";
        store.commit("updateTitle", title);
      } else if (originType == "RegulationOperation") {
        if (this.active === 0) {
          this.RegulationOperationList = data;
        } else {
          this.RegulationOperationList2 = data;
        }
        title = "操作规程";
      }
      store.commit("updateTitle", title);
    },
    calcTitle() {
      let originType = this.$route.query.titleCode;
      let title;
      if (originType == "RegulationManual") {
        title = "管理手册";
      } else if (originType == "RegulationOperation") {
        title = "操作规程";
      }
      store.commit("updateTitle", title);
    },
    goDetail(item) {
      if (this.titleCode == "RegulationManual") {
        this.$router.push({
          path: "/RegulatoryFramework/Detail",
          query: { id: item.ID, titleCode: this.$route.query.titleCode },
        });
      } else if (this.titleCode == "RegulationOperation") {
        this.$router.push({
          path: "/RegulatoryFramework/Detail",
          query: { id: item.ID, titleCode: this.$route.query.titleCode },
        });
      }
    },
  },
};
</script>

<style lang="less" scoped>
.van-cell.card {
  border-radius: 0.16rem;
  background-color: #ffffff;
  padding: 0.26667rem;
  margin-top: 0.26667rem;
  margin-left: 0.26667rem;
  margin-right: 0.26667rem;
  width: auto;
}
</style>
